{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Boxplot\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.charts import WordCloud\n",
    "from pyecharts.globals import SymbolType\n",
    "import numpy as np\n",
    "from snownlp import SnowNLP\n",
    "import jieba\n",
    "# from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator\n",
    "from matplotlib import pyplot as plt\n",
    "import os\n",
    "import collections\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "大类清单如下：\n",
      "{'服装、鞋靴、箱包、配饰', '保健品、运动户外、器械', '手机、数码、电脑', '化妆品、洗护沐浴', '厨房用品、厨房电器', '母婴、玩具、宠物', '珠宝、收藏、钟表', '家居、家饰', '食品饮料', '家用电器', '汽车、旅游、保险、服务'}\n",
      "共有 11 个大类\n"
     ]
    }
   ],
   "source": [
    "data_pre = pd.read_csv('./data_list/data_list_after_groupby.csv', sep=',', header=0, encoding='utf-8',engine='python',dtype=str)\n",
    "all_titles = set(data_pre['title'])\n",
    "print('大类清单如下：\\n{0}\\n共有 {1} 个大类'.format(all_titles,len(all_titles)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "title_class = '厨房用品、厨房电器'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "导出数据共有24203行，8列！\n",
      "读取数据源成功！！\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"953fa6122eff492d82f19a4d11b9a72a\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        var chart_953fa6122eff492d82f19a4d11b9a72a = echarts.init(\n",
       "            document.getElementById('953fa6122eff492d82f19a4d11b9a72a'), 'white', {renderer: 'canvas'});\n",
       "        var option_953fa6122eff492d82f19a4d11b9a72a = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u5c0f\\u7c7b\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    109.0,\n",
       "                    149.0,\n",
       "                    2698.0,\n",
       "                    699.0,\n",
       "                    209.0,\n",
       "                    69.0,\n",
       "                    199.0,\n",
       "                    129.0,\n",
       "                    309.0,\n",
       "                    99.0\n",
       "                ],\n",
       "                [\n",
       "                    299.0,\n",
       "                    268.0,\n",
       "                    69.0,\n",
       "                    318.0,\n",
       "                    75.0,\n",
       "                    99.0,\n",
       "                    129.0,\n",
       "                    199.0,\n",
       "                    238.0,\n",
       "                    149.0,\n",
       "                    390.0,\n",
       "                    459.0,\n",
       "                    59.0,\n",
       "                    79.0,\n",
       "                    486.0,\n",
       "                    98.0,\n",
       "                    358.0,\n",
       "                    359.0,\n",
       "                    139.0,\n",
       "                    289.0,\n",
       "                    249.0,\n",
       "                    208.0,\n",
       "                    109.0,\n",
       "                    89.0,\n",
       "                    168.0,\n",
       "                    308.0,\n",
       "                    428.0,\n",
       "                    518.0,\n",
       "                    398.0,\n",
       "                    499.0,\n",
       "                    388.0,\n",
       "                    258.0,\n",
       "                    638.0,\n",
       "                    498.0,\n",
       "                    128.0,\n",
       "                    158.0,\n",
       "                    78.0,\n",
       "                    138.0,\n",
       "                    68.0,\n",
       "                    399.0,\n",
       "                    369.0,\n",
       "                    489.0,\n",
       "                    468.0,\n",
       "                    508.0,\n",
       "                    389.0,\n",
       "                    418.0,\n",
       "                    798.0,\n",
       "                    348.0,\n",
       "                    456.0,\n",
       "                    479.0,\n",
       "                    458.0,\n",
       "                    228.0,\n",
       "                    339.0,\n",
       "                    259.0,\n",
       "                    118.0,\n",
       "                    148.0,\n",
       "                    218.0,\n",
       "                    169.0,\n",
       "                    188.0,\n",
       "                    278.0,\n",
       "                    368.0\n",
       "                ],\n",
       "                [\n",
       "                    159.0,\n",
       "                    899.0,\n",
       "                    299.0,\n",
       "                    339.0,\n",
       "                    199.0,\n",
       "                    179.0,\n",
       "                    99.0,\n",
       "                    239.0,\n",
       "                    129.0,\n",
       "                    169.0,\n",
       "                    89.0,\n",
       "                    198.0,\n",
       "                    228.0,\n",
       "                    368.0,\n",
       "                    238.0,\n",
       "                    298.0,\n",
       "                    139.0,\n",
       "                    459.0,\n",
       "                    269.0,\n",
       "                    248.0,\n",
       "                    149.0,\n",
       "                    69.0,\n",
       "                    1788.0,\n",
       "                    498.0,\n",
       "                    189.0,\n",
       "                    249.0,\n",
       "                    318.0,\n",
       "                    499.0,\n",
       "                    219.0,\n",
       "                    118.0,\n",
       "                    488.0,\n",
       "                    349.0,\n",
       "                    188.0,\n",
       "                    369.0,\n",
       "                    218.0,\n",
       "                    688.0,\n",
       "                    268.0\n",
       "                ],\n",
       "                [\n",
       "                    190.0,\n",
       "                    899.0,\n",
       "                    109.0,\n",
       "                    39.9,\n",
       "                    199.0,\n",
       "                    93.0,\n",
       "                    239.0,\n",
       "                    99.0,\n",
       "                    49.0,\n",
       "                    89.0,\n",
       "                    79.0,\n",
       "                    159.0,\n",
       "                    188.0,\n",
       "                    258.0,\n",
       "                    59.0,\n",
       "                    278.0,\n",
       "                    229.0,\n",
       "                    119.0,\n",
       "                    129.0,\n",
       "                    298.0,\n",
       "                    169.0,\n",
       "                    268.0,\n",
       "                    1980.0,\n",
       "                    39.0,\n",
       "                    399.0,\n",
       "                    69.0,\n",
       "                    218.0,\n",
       "                    108.0,\n",
       "                    139.0,\n",
       "                    149.0,\n",
       "                    118.0,\n",
       "                    179.0,\n",
       "                    498.0,\n",
       "                    138.0,\n",
       "                    100.0,\n",
       "                    128.0,\n",
       "                    398.0,\n",
       "                    115.0,\n",
       "                    66.0,\n",
       "                    123.0,\n",
       "                    85.0,\n",
       "                    29.0,\n",
       "                    53.0,\n",
       "                    62.0,\n",
       "                    77.0,\n",
       "                    96.0,\n",
       "                    358.0,\n",
       "                    156.0,\n",
       "                    178.0,\n",
       "                    166.0,\n",
       "                    168.0,\n",
       "                    148.0,\n",
       "                    699.0,\n",
       "                    189.0\n",
       "                ],\n",
       "                [\n",
       "                    299.0,\n",
       "                    149.0,\n",
       "                    799.0,\n",
       "                    99.0,\n",
       "                    548.0,\n",
       "                    79.0,\n",
       "                    38.0,\n",
       "                    399.0,\n",
       "                    599.0,\n",
       "                    199.0,\n",
       "                    169.0,\n",
       "                    259.0,\n",
       "                    98.0,\n",
       "                    198.0,\n",
       "                    698.0,\n",
       "                    449.0,\n",
       "                    124.0,\n",
       "                    115.0,\n",
       "                    39.0,\n",
       "                    58.0,\n",
       "                    730.0,\n",
       "                    138.0,\n",
       "                    139.0,\n",
       "                    129.0,\n",
       "                    119.0,\n",
       "                    549.0,\n",
       "                    339.0,\n",
       "                    122.0,\n",
       "                    159.0,\n",
       "                    29.0,\n",
       "                    179.0,\n",
       "                    109.0,\n",
       "                    738.0,\n",
       "                    998.0,\n",
       "                    559.0,\n",
       "                    519.0,\n",
       "                    499.0,\n",
       "                    89.0,\n",
       "                    1288.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    158.0,\n",
       "                    69.0,\n",
       "                    198.0,\n",
       "                    78.0,\n",
       "                    108.0,\n",
       "                    138.0,\n",
       "                    159.0,\n",
       "                    119.0,\n",
       "                    339.0,\n",
       "                    228.0,\n",
       "                    30.0,\n",
       "                    258.0,\n",
       "                    199.0,\n",
       "                    49.0,\n",
       "                    48.0,\n",
       "                    39.0,\n",
       "                    59.0,\n",
       "                    265.0,\n",
       "                    58.0,\n",
       "                    88.0,\n",
       "                    68.0,\n",
       "                    139.0,\n",
       "                    128.0,\n",
       "                    259.0,\n",
       "                    179.0,\n",
       "                    268.0,\n",
       "                    149.0,\n",
       "                    129.0,\n",
       "                    118.0,\n",
       "                    299.0,\n",
       "                    499.0,\n",
       "                    399.0\n",
       "                ],\n",
       "                [\n",
       "                    129.0,\n",
       "                    99.0,\n",
       "                    65.0,\n",
       "                    56.8,\n",
       "                    39.0,\n",
       "                    118.0,\n",
       "                    50.0,\n",
       "                    138.0,\n",
       "                    29.0,\n",
       "                    288.0,\n",
       "                    269.0,\n",
       "                    128.0,\n",
       "                    108.0,\n",
       "                    358.0,\n",
       "                    298.0,\n",
       "                    109.0,\n",
       "                    119.0,\n",
       "                    98.0,\n",
       "                    228.0,\n",
       "                    1598.0,\n",
       "                    149.0,\n",
       "                    148.0,\n",
       "                    899.0,\n",
       "                    169.0,\n",
       "                    135.0,\n",
       "                    248.0,\n",
       "                    208.0,\n",
       "                    35.0,\n",
       "                    139.0,\n",
       "                    268.0,\n",
       "                    112.0,\n",
       "                    218.0,\n",
       "                    189.0,\n",
       "                    198.0,\n",
       "                    199.0,\n",
       "                    69.0,\n",
       "                    79.0,\n",
       "                    49.0,\n",
       "                    59.0,\n",
       "                    66.0,\n",
       "                    57.0,\n",
       "                    115.0,\n",
       "                    51.9,\n",
       "                    89.0,\n",
       "                    226.0,\n",
       "                    249.0,\n",
       "                    83.0,\n",
       "                    58.0,\n",
       "                    2199.0,\n",
       "                    319.0,\n",
       "                    2499.0,\n",
       "                    3999.0,\n",
       "                    39.9,\n",
       "                    27.0,\n",
       "                    48.0,\n",
       "                    157.0,\n",
       "                    162.0,\n",
       "                    188.0,\n",
       "                    159.0,\n",
       "                    599.0,\n",
       "                    280.0\n",
       "                ],\n",
       "                [\n",
       "                    239.0,\n",
       "                    469.0,\n",
       "                    599.0,\n",
       "                    709.0,\n",
       "                    748.0,\n",
       "                    999.0,\n",
       "                    799.0,\n",
       "                    699.0,\n",
       "                    299.0,\n",
       "                    300.0,\n",
       "                    187.0,\n",
       "                    1799.0,\n",
       "                    1189.0,\n",
       "                    1299.0,\n",
       "                    1399.0,\n",
       "                    1499.0,\n",
       "                    1159.0,\n",
       "                    180.0,\n",
       "                    1366.0,\n",
       "                    1129.0,\n",
       "                    456.0,\n",
       "                    178.0,\n",
       "                    569.0\n",
       "                ],\n",
       "                [\n",
       "                    89.0,\n",
       "                    99.0,\n",
       "                    3888.0,\n",
       "                    3899.0,\n",
       "                    4699.0,\n",
       "                    169.0,\n",
       "                    4999.0,\n",
       "                    6399.0,\n",
       "                    4799.0,\n",
       "                    149.0,\n",
       "                    329.0,\n",
       "                    299.0,\n",
       "                    1788.0,\n",
       "                    699.0,\n",
       "                    399.0,\n",
       "                    4688.0,\n",
       "                    4288.0,\n",
       "                    2980.0\n",
       "                ],\n",
       "                [\n",
       "                    1998.0,\n",
       "                    588.0,\n",
       "                    698.0,\n",
       "                    499.0,\n",
       "                    568.0,\n",
       "                    399.0,\n",
       "                    2998.0,\n",
       "                    1788.0,\n",
       "                    1188.0,\n",
       "                    2298.0,\n",
       "                    169.0,\n",
       "                    998.0,\n",
       "                    699.0,\n",
       "                    888.0,\n",
       "                    2488.0,\n",
       "                    2698.0,\n",
       "                    1499.0,\n",
       "                    1399.0,\n",
       "                    468.0,\n",
       "                    1299.0,\n",
       "                    299.0,\n",
       "                    2588.0,\n",
       "                    2288.0,\n",
       "                    999.0,\n",
       "                    680.0\n",
       "                ],\n",
       "                [\n",
       "                    1680.0,\n",
       "                    1980.0,\n",
       "                    998.0,\n",
       "                    799.0,\n",
       "                    1890.0,\n",
       "                    2599.0,\n",
       "                    319.0,\n",
       "                    329.0,\n",
       "                    1999.0,\n",
       "                    10880.0,\n",
       "                    3599.0,\n",
       "                    199.0,\n",
       "                    499.0,\n",
       "                    698.0,\n",
       "                    1398.0,\n",
       "                    899.0,\n",
       "                    6799.0,\n",
       "                    1490.0,\n",
       "                    999.0,\n",
       "                    169.0,\n",
       "                    699.0,\n",
       "                    1799.0\n",
       "                ],\n",
       "                [\n",
       "                    3380.0,\n",
       "                    2299.0,\n",
       "                    3999.0,\n",
       "                    2980.0,\n",
       "                    3980.0,\n",
       "                    4780.0,\n",
       "                    2180.0,\n",
       "                    3580.0,\n",
       "                    3480.0,\n",
       "                    4990.0,\n",
       "                    5080.0,\n",
       "                    588.0,\n",
       "                    2880.0,\n",
       "                    3599.0,\n",
       "                    4380.0,\n",
       "                    1790.0,\n",
       "                    5380.0,\n",
       "                    2480.0,\n",
       "                    1590.0,\n",
       "                    4299.0,\n",
       "                    1299.0,\n",
       "                    1699.0,\n",
       "                    4099.0,\n",
       "                    1898.0,\n",
       "                    1899.0,\n",
       "                    3180.0,\n",
       "                    2599.0,\n",
       "                    2499.0,\n",
       "                    3280.0,\n",
       "                    899.0,\n",
       "                    829.0,\n",
       "                    3990.0,\n",
       "                    4580.0,\n",
       "                    688.0,\n",
       "                    3080.0,\n",
       "                    6990.0,\n",
       "                    699.0,\n",
       "                    4180.0,\n",
       "                    2280.0,\n",
       "                    3680.0,\n",
       "                    7999.0,\n",
       "                    8260.0,\n",
       "                    3780.0,\n",
       "                    4680.0,\n",
       "                    1640.0,\n",
       "                    4699.0,\n",
       "                    2780.0,\n",
       "                    5780.0,\n",
       "                    5280.0,\n",
       "                    3499.0,\n",
       "                    3299.0,\n",
       "                    4599.0,\n",
       "                    698.0,\n",
       "                    658.0,\n",
       "                    5980.0,\n",
       "                    4999.0,\n",
       "                    1099.0,\n",
       "                    1499.0,\n",
       "                    1599.0,\n",
       "                    3399.0,\n",
       "                    1999.0,\n",
       "                    998.0,\n",
       "                    999.0,\n",
       "                    2680.0,\n",
       "                    4590.0,\n",
       "                    5299.0,\n",
       "                    2380.0,\n",
       "                    798.0,\n",
       "                    2999.0,\n",
       "                    1890.0,\n",
       "                    4199.0,\n",
       "                    2690.0,\n",
       "                    2890.0,\n",
       "                    2190.0,\n",
       "                    5290.0,\n",
       "                    3099.0,\n",
       "                    3799.0,\n",
       "                    3699.0,\n",
       "                    2290.0,\n",
       "                    1880.0,\n",
       "                    499.0,\n",
       "                    729.0,\n",
       "                    1199.0\n",
       "                ],\n",
       "                [\n",
       "                    158.0,\n",
       "                    2980.0,\n",
       "                    49.0,\n",
       "                    168.0,\n",
       "                    138.0,\n",
       "                    199.0\n",
       "                ],\n",
       "                [\n",
       "                    398.0,\n",
       "                    69.0,\n",
       "                    3980.0,\n",
       "                    699.0,\n",
       "                    189.0,\n",
       "                    114.0,\n",
       "                    328.0,\n",
       "                    169.0,\n",
       "                    399.0,\n",
       "                    669.0,\n",
       "                    999.0,\n",
       "                    139.0,\n",
       "                    149.0,\n",
       "                    689.0,\n",
       "                    1998.0,\n",
       "                    259.0,\n",
       "                    299.0,\n",
       "                    298.0,\n",
       "                    199.0,\n",
       "                    2098.0,\n",
       "                    499.0,\n",
       "                    269.0,\n",
       "                    1088.0,\n",
       "                    1299.0,\n",
       "                    249.0,\n",
       "                    1898.0,\n",
       "                    369.0,\n",
       "                    179.0,\n",
       "                    1499.0,\n",
       "                    219.0,\n",
       "                    1099.0,\n",
       "                    1980.0,\n",
       "                    1080.0,\n",
       "                    1698.0,\n",
       "                    1999.0,\n",
       "                    1498.0,\n",
       "                    1399.0,\n",
       "                    2999.0,\n",
       "                    119.0,\n",
       "                    79.0,\n",
       "                    789.0,\n",
       "                    4299.0,\n",
       "                    99.0,\n",
       "                    238.0,\n",
       "                    1380.0,\n",
       "                    409.0,\n",
       "                    599.0,\n",
       "                    8800.0,\n",
       "                    899.0,\n",
       "                    429.0,\n",
       "                    889.0,\n",
       "                    390.0,\n",
       "                    1799.0,\n",
       "                    7800.0,\n",
       "                    128.0,\n",
       "                    988.0,\n",
       "                    419.0,\n",
       "                    198.0,\n",
       "                    1199.0,\n",
       "                    1180.0\n",
       "                ],\n",
       "                [\n",
       "                    78.0,\n",
       "                    68.0,\n",
       "                    79.0,\n",
       "                    138.0,\n",
       "                    168.0,\n",
       "                    128.0,\n",
       "                    108.0,\n",
       "                    268.0,\n",
       "                    398.0,\n",
       "                    158.0,\n",
       "                    129.0,\n",
       "                    29.9,\n",
       "                    198.0,\n",
       "                    698.0,\n",
       "                    59.0,\n",
       "                    148.0,\n",
       "                    36.8,\n",
       "                    139.0,\n",
       "                    188.0,\n",
       "                    368.0,\n",
       "                    228.0,\n",
       "                    58.0,\n",
       "                    628.0,\n",
       "                    144.0,\n",
       "                    218.0,\n",
       "                    230.0,\n",
       "                    199.0,\n",
       "                    99.0,\n",
       "                    89.0,\n",
       "                    98.0,\n",
       "                    888.0,\n",
       "                    39.0,\n",
       "                    48.0,\n",
       "                    69.0,\n",
       "                    88.0,\n",
       "                    298.0,\n",
       "                    1980.0,\n",
       "                    458.0,\n",
       "                    788.0,\n",
       "                    258.0,\n",
       "                    999.0,\n",
       "                    338.0,\n",
       "                    1888.0,\n",
       "                    438.0,\n",
       "                    269.0,\n",
       "                    989.0,\n",
       "                    299.0\n",
       "                ],\n",
       "                [\n",
       "                    199.0,\n",
       "                    699.0,\n",
       "                    209.0,\n",
       "                    998.0,\n",
       "                    169.0,\n",
       "                    119.0,\n",
       "                    598.0,\n",
       "                    259.0,\n",
       "                    448.0,\n",
       "                    468.0,\n",
       "                    369.0,\n",
       "                    349.0,\n",
       "                    189.0,\n",
       "                    599.0,\n",
       "                    363.0,\n",
       "                    999.0,\n",
       "                    319.0\n",
       "                ],\n",
       "                [\n",
       "                    149.0,\n",
       "                    199.0,\n",
       "                    298.0,\n",
       "                    248.0,\n",
       "                    1799.0,\n",
       "                    129.0,\n",
       "                    139.0,\n",
       "                    699.0,\n",
       "                    279.0,\n",
       "                    259.0,\n",
       "                    228.0,\n",
       "                    439.0,\n",
       "                    398.0,\n",
       "                    269.0,\n",
       "                    219.0,\n",
       "                    799.0,\n",
       "                    299.0,\n",
       "                    239.0,\n",
       "                    459.0,\n",
       "                    268.0,\n",
       "                    1588.0,\n",
       "                    1099.0,\n",
       "                    289.0,\n",
       "                    339.0,\n",
       "                    359.0,\n",
       "                    599.0,\n",
       "                    1458.0,\n",
       "                    1299.0,\n",
       "                    988.0,\n",
       "                    899.0,\n",
       "                    998.0,\n",
       "                    999.0,\n",
       "                    1899.0,\n",
       "                    1999.0,\n",
       "                    2199.0,\n",
       "                    2399.0,\n",
       "                    1699.0,\n",
       "                    399.0,\n",
       "                    2680.0,\n",
       "                    2288.0,\n",
       "                    1499.0,\n",
       "                    449.0,\n",
       "                    869.0,\n",
       "                    1399.0,\n",
       "                    379.0,\n",
       "                    498.0\n",
       "                ],\n",
       "                [\n",
       "                    599.0,\n",
       "                    798.0,\n",
       "                    109.0,\n",
       "                    99.0,\n",
       "                    129.0,\n",
       "                    258.0,\n",
       "                    119.0,\n",
       "                    249.0,\n",
       "                    149.0,\n",
       "                    229.0,\n",
       "                    169.0,\n",
       "                    299.0,\n",
       "                    199.0,\n",
       "                    239.0,\n",
       "                    399.0,\n",
       "                    369.0,\n",
       "                    329.0,\n",
       "                    1399.0\n",
       "                ],\n",
       "                [\n",
       "                    69.0,\n",
       "                    129.0,\n",
       "                    99.0,\n",
       "                    59.0,\n",
       "                    269.0,\n",
       "                    159.0,\n",
       "                    149.0,\n",
       "                    109.0,\n",
       "                    119.0\n",
       "                ],\n",
       "                [\n",
       "                    698.0,\n",
       "                    209.0,\n",
       "                    1098.0,\n",
       "                    398.0,\n",
       "                    699.0,\n",
       "                    99.0,\n",
       "                    256.0,\n",
       "                    898.0,\n",
       "                    799.0,\n",
       "                    189.0,\n",
       "                    169.0,\n",
       "                    539.0,\n",
       "                    529.0,\n",
       "                    818.0,\n",
       "                    599.0,\n",
       "                    498.0,\n",
       "                    598.0,\n",
       "                    658.0,\n",
       "                    499.0,\n",
       "                    359.0,\n",
       "                    430.0,\n",
       "                    559.0,\n",
       "                    429.0,\n",
       "                    1280.0,\n",
       "                    2998.0,\n",
       "                    399.0,\n",
       "                    998.0,\n",
       "                    218.0,\n",
       "                    999.0,\n",
       "                    148.0\n",
       "                ],\n",
       "                [\n",
       "                    399.0,\n",
       "                    599.0,\n",
       "                    999.0,\n",
       "                    1520.0,\n",
       "                    899.0,\n",
       "                    199.0,\n",
       "                    699.0\n",
       "                ],\n",
       "                [\n",
       "                    298.0,\n",
       "                    239.0,\n",
       "                    548.0,\n",
       "                    139.0,\n",
       "                    259.0,\n",
       "                    109.0,\n",
       "                    498.0,\n",
       "                    299.0,\n",
       "                    129.0,\n",
       "                    119.0,\n",
       "                    269.0,\n",
       "                    1199.0,\n",
       "                    149.0,\n",
       "                    199.0,\n",
       "                    99.0,\n",
       "                    169.0,\n",
       "                    1099.0,\n",
       "                    50.0,\n",
       "                    499.0,\n",
       "                    399.0,\n",
       "                    329.0,\n",
       "                    229.0,\n",
       "                    690.0,\n",
       "                    769.0,\n",
       "                    1999.0,\n",
       "                    138.0,\n",
       "                    1348.0,\n",
       "                    179.0,\n",
       "                    1548.0,\n",
       "                    999.0,\n",
       "                    599.0,\n",
       "                    289.0,\n",
       "                    339.0,\n",
       "                    1389.0,\n",
       "                    3999.0,\n",
       "                    799.0,\n",
       "                    248.0,\n",
       "                    258.0,\n",
       "                    1299.0,\n",
       "                    1498.0,\n",
       "                    1098.0,\n",
       "                    899.0,\n",
       "                    699.0,\n",
       "                    1399.0,\n",
       "                    238.0,\n",
       "                    359.0,\n",
       "                    198.0,\n",
       "                    178.0,\n",
       "                    1280.0,\n",
       "                    528.0,\n",
       "                    398.0,\n",
       "                    890.0,\n",
       "                    459.0,\n",
       "                    1388.0,\n",
       "                    1858.0,\n",
       "                    558.0,\n",
       "                    1488.0,\n",
       "                    2888.0,\n",
       "                    309.0,\n",
       "                    103.0\n",
       "                ],\n",
       "                [\n",
       "                    99.0,\n",
       "                    299.0,\n",
       "                    499.0,\n",
       "                    239.0,\n",
       "                    369.0,\n",
       "                    129.0,\n",
       "                    169.0,\n",
       "                    149.0,\n",
       "                    199.0,\n",
       "                    259.0,\n",
       "                    229.0,\n",
       "                    328.0,\n",
       "                    139.0,\n",
       "                    209.0,\n",
       "                    1090.0,\n",
       "                    159.0,\n",
       "                    179.0,\n",
       "                    1699.0,\n",
       "                    359.0,\n",
       "                    399.0,\n",
       "                    379.0,\n",
       "                    88.0,\n",
       "                    599.0,\n",
       "                    269.0,\n",
       "                    1299.0,\n",
       "                    219.0,\n",
       "                    309.0,\n",
       "                    189.0,\n",
       "                    1028.0,\n",
       "                    188.0,\n",
       "                    148.0,\n",
       "                    238.0,\n",
       "                    439.0,\n",
       "                    998.0,\n",
       "                    1039.0,\n",
       "                    268.0\n",
       "                ],\n",
       "                [\n",
       "                    1998.0,\n",
       "                    99.0,\n",
       "                    399.0,\n",
       "                    249.0,\n",
       "                    199.0,\n",
       "                    299.0,\n",
       "                    1080.0,\n",
       "                    1099.0,\n",
       "                    329.0,\n",
       "                    498.0,\n",
       "                    1298.0,\n",
       "                    1299.0,\n",
       "                    1498.0,\n",
       "                    358.0,\n",
       "                    1198.0,\n",
       "                    1049.0,\n",
       "                    139.0,\n",
       "                    1698.0,\n",
       "                    1196.0,\n",
       "                    1598.0,\n",
       "                    599.0,\n",
       "                    2500.0,\n",
       "                    3399.0\n",
       "                ],\n",
       "                [\n",
       "                    1899.0,\n",
       "                    3398.0,\n",
       "                    499.0,\n",
       "                    1428.0,\n",
       "                    469.0,\n",
       "                    269.0,\n",
       "                    299.0,\n",
       "                    1999.0,\n",
       "                    1499.0,\n",
       "                    399.0,\n",
       "                    3980.0,\n",
       "                    548.0,\n",
       "                    249.0,\n",
       "                    199.0,\n",
       "                    1399.0,\n",
       "                    599.0,\n",
       "                    2598.0,\n",
       "                    899.0,\n",
       "                    488.0,\n",
       "                    2238.0,\n",
       "                    3799.0,\n",
       "                    1258.0,\n",
       "                    5999.0,\n",
       "                    239.0,\n",
       "                    189.0,\n",
       "                    799.0,\n",
       "                    3599.0,\n",
       "                    2498.0,\n",
       "                    1998.0,\n",
       "                    2198.0,\n",
       "                    1598.0,\n",
       "                    1380.0,\n",
       "                    2368.0,\n",
       "                    5288.0,\n",
       "                    7999.0,\n",
       "                    388.0,\n",
       "                    129.0,\n",
       "                    139.0,\n",
       "                    2180.0,\n",
       "                    2998.0,\n",
       "                    1299.0,\n",
       "                    109.0,\n",
       "                    179.0,\n",
       "                    15888.0,\n",
       "                    339.0,\n",
       "                    1498.0,\n",
       "                    628.0,\n",
       "                    1188.0,\n",
       "                    2398.0,\n",
       "                    1680.0,\n",
       "                    1298.0,\n",
       "                    699.0,\n",
       "                    798.0,\n",
       "                    4998.0,\n",
       "                    2099.0,\n",
       "                    9799.0,\n",
       "                    4199.0\n",
       "                ],\n",
       "                [\n",
       "                    209.0,\n",
       "                    179.0,\n",
       "                    169.0,\n",
       "                    599.0,\n",
       "                    219.0,\n",
       "                    239.0,\n",
       "                    588.0,\n",
       "                    1299.0,\n",
       "                    158.0\n",
       "                ],\n",
       "                [\n",
       "                    299.0,\n",
       "                    149.0,\n",
       "                    99.0,\n",
       "                    108.0,\n",
       "                    138.0,\n",
       "                    198.0,\n",
       "                    239.0,\n",
       "                    49.0,\n",
       "                    335.0,\n",
       "                    68.0,\n",
       "                    189.0,\n",
       "                    78.0,\n",
       "                    168.0,\n",
       "                    118.0,\n",
       "                    238.0,\n",
       "                    129.0\n",
       "                ],\n",
       "                [\n",
       "                    2580.0,\n",
       "                    3680.0,\n",
       "                    1799.0,\n",
       "                    8299.0,\n",
       "                    3999.0,\n",
       "                    2399.0,\n",
       "                    1698.0\n",
       "                ],\n",
       "                [\n",
       "                    358.0,\n",
       "                    1199.0,\n",
       "                    399.0,\n",
       "                    1098.0,\n",
       "                    498.0\n",
       "                ],\n",
       "                [\n",
       "                    398.0,\n",
       "                    189.0,\n",
       "                    73.0,\n",
       "                    3980.0,\n",
       "                    498.0\n",
       "                ],\n",
       "                [\n",
       "                    169.0,\n",
       "                    309.0,\n",
       "                    129.0,\n",
       "                    79.0,\n",
       "                    239.0,\n",
       "                    269.0,\n",
       "                    139.0,\n",
       "                    99.0,\n",
       "                    199.0\n",
       "                ],\n",
       "                [\n",
       "                    599.0,\n",
       "                    149.0,\n",
       "                    295.0,\n",
       "                    299.0,\n",
       "                    179.0,\n",
       "                    279.0,\n",
       "                    269.0,\n",
       "                    499.0,\n",
       "                    719.0,\n",
       "                    3218.0,\n",
       "                    688.0,\n",
       "                    549.0\n",
       "                ],\n",
       "                [\n",
       "                    45.0,\n",
       "                    39.8,\n",
       "                    139.0,\n",
       "                    59.8,\n",
       "                    299.0,\n",
       "                    99.0,\n",
       "                    329.0,\n",
       "                    25.8,\n",
       "                    56.8,\n",
       "                    129.0,\n",
       "                    298.0,\n",
       "                    1999.0,\n",
       "                    124.0,\n",
       "                    183.0,\n",
       "                    36.8,\n",
       "                    49.0,\n",
       "                    258.0,\n",
       "                    399.0,\n",
       "                    98888.0,\n",
       "                    39.9,\n",
       "                    108.0,\n",
       "                    48.0,\n",
       "                    292.0,\n",
       "                    111.0,\n",
       "                    51.0,\n",
       "                    39.0,\n",
       "                    79.8,\n",
       "                    165.0,\n",
       "                    398.0,\n",
       "                    59.0,\n",
       "                    29.8,\n",
       "                    60.0,\n",
       "                    198.0,\n",
       "                    189.0,\n",
       "                    209.0,\n",
       "                    68.0,\n",
       "                    158.0,\n",
       "                    118.0,\n",
       "                    38.0,\n",
       "                    109.0,\n",
       "                    408.0,\n",
       "                    199.0,\n",
       "                    149.0,\n",
       "                    128.0,\n",
       "                    368.0,\n",
       "                    119.0,\n",
       "                    138.0,\n",
       "                    559.0,\n",
       "                    136.0,\n",
       "                    113.0,\n",
       "                    159.0,\n",
       "                    169.0,\n",
       "                    137.0,\n",
       "                    775.0,\n",
       "                    388.0,\n",
       "                    219.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c7b\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5c0f\\u7c7b\": true\n",
       "            },\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLabel\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"rotate\": -90,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"\\u9910\\u5177\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6309\\u5c0f\\u7c7b\\u7bb1\\u7ebf\\u56fe\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_953fa6122eff492d82f19a4d11b9a72a.setOption(option_953fa6122eff492d82f19a4d11b9a72a);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x297404551d0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = pd.read_csv('./data_list/data_list_after_groupby.csv', sep=',', header=0, encoding='utf-8',engine='python',dtype=str)\n",
    "# data = data.iloc[:10001, :]\n",
    "data = data[data['title'] == title_class]\n",
    "print('导出数据共有{}行，{}列！'.format(data.shape[0], data.shape[1]))\n",
    "print('读取数据源成功！！')   \n",
    "    \n",
    "# 按小类箱线图检测异常值  ——  pyecharts\n",
    "title_name = data['cate'].unique()\n",
    "title_name = list(title_name)\n",
    "title_price = []\n",
    "for title in title_name:\n",
    "    pro_price = data[data['cate']==title]['pro_price'].astype(float).unique()\n",
    "    pro_price = list(pro_price)\n",
    "    title_price.append(pro_price)\n",
    "# print(f'title_price是 {np.array(title_price).shape[0]}维数据')\n",
    "file_name = 'boxplot_' + title_class + '_output.html'\n",
    "# boxplot = Boxplot('按小类箱线图检测异常值',width=1500, height=400)\n",
    "# x_axis = title_name\n",
    "# y_axis = title_price\n",
    "# _yaxis = boxplot.prepare_data(y_axis)\n",
    "# boxplot.add('小类', x_axis, _yaxis,xaxis_rotate=45,width=1600,height=800)\n",
    "# boxplot.render(os.path.join('./data_list',file_name))\n",
    "# boxplot\n",
    "boxplot = (Boxplot().add_xaxis(title_name).add_yaxis('小类', title_price).set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-90)),title_opts=opts.TitleOpts(title='按小类箱线图')))\n",
    "boxplot.render_notebook()\n",
    "# boxplot.render(os.path.join('./data_list',file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"0b0bb54d5dbc4729886885b8e4ca847e\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        var chart_0b0bb54d5dbc4729886885b8e4ca847e = echarts.init(\n",
       "            document.getElementById('0b0bb54d5dbc4729886885b8e4ca847e'), 'white', {renderer: 'canvas'});\n",
       "        var option_0b0bb54d5dbc4729886885b8e4ca847e = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8bc4\\u5206\\u533a\\u95f4\",\n",
       "            \"data\": [\n",
       "                3127.0,\n",
       "                1070.0,\n",
       "                912.0,\n",
       "                812.0,\n",
       "                921.0,\n",
       "                1040.0,\n",
       "                1255.0,\n",
       "                1568.0,\n",
       "                2490.0,\n",
       "                11008.0\n",
       "            ],\n",
       "            \"barCategoryGap\": 0,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8bc4\\u5206\\u533a\\u95f4\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8bc4\\u5206\\u533a\\u95f4\": true\n",
       "            },\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"0\",\n",
       "                \"0.1\",\n",
       "                \"0.2\",\n",
       "                \"0.3\",\n",
       "                \"0.4\",\n",
       "                \"0.5\",\n",
       "                \"0.6\",\n",
       "                \"0.7\",\n",
       "                \"0.8\",\n",
       "                \"0.9\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u5206\\u533a\\u95f4\\u76f4\\u65b9\\u56fe\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_0b0bb54d5dbc4729886885b8e4ca847e.setOption(option_0b0bb54d5dbc4729886885b8e4ca847e);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2107cb42b70>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评分区间直方图  ——  pyecharts\n",
    "sentiment_score = data['sentiment_score'].astype(float)\n",
    "group = [0, 0.1, 0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]\n",
    "data['group_num'] = pd.cut(sentiment_score, group, labels=['0', '0.1', '0.2', '0.3','0.4','0.5','0.6','0.7','0.8','0.9','1.0'],right=False)\n",
    "data_hist = pd.pivot_table(data,index=['group_num'],values=['sentiment_score'],aggfunc=[len])\n",
    "data_hist.reset_index(inplace=True)\n",
    "data_hist.sort_values(by='group_num',ascending=True,inplace=True)\n",
    "x_axis_list = list(data_hist['group_num'])\n",
    "y_axis_list = list(data_hist[('len','sentiment_score')])\n",
    "# print(x_axis_list,y_axis_list)\n",
    "# bar = Bar('评分区间直方图 ')\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# bar.add('评分区间', x_axis, y_axis,bar_category_gap=0,is_label_show=True)\n",
    "file_name = 'hist_' + title_class + '_output.html'\n",
    "# bar.render(os.path.join('./data_list',file_name))\n",
    "# bar\n",
    "bar = (Bar().add_xaxis(x_axis_list).add_yaxis('评分区间', y_axis_list,category_gap=0).set_global_opts(title_opts=opts.TitleOpts(title='评分区间直方图')))\n",
    "bar.render_notebook()\n",
    "# bar.render(os.path.join('./data_list',file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1    好评\n",
      "2    差评\n",
      "0    中评\n",
      "Name: group, dtype: object 1    15718\n",
      "2     5503\n",
      "0     2982\n",
      "Name: (len, item_id), dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"764090eaa76c4370812ab40c819cd724\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        var chart_764090eaa76c4370812ab40c819cd724 = echarts.init(\n",
       "            document.getElementById('764090eaa76c4370812ab40c819cd724'), 'white', {renderer: 'canvas'});\n",
       "        var option_764090eaa76c4370812ab40c819cd724 = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u8bc4\",\n",
       "                    \"value\": 15718\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5dee\\u8bc4\",\n",
       "                    \"value\": 5503\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u8bc4\",\n",
       "                    \"value\": 2982\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"40%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {d}%\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u597d\\u8bc4\",\n",
       "                \"\\u5dee\\u8bc4\",\n",
       "                \"\\u4e2d\\u8bc4\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\"\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u8bba\\u5206\\u7c7b\\u997c\\u56fe\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_764090eaa76c4370812ab40c819cd724.setOption(option_764090eaa76c4370812ab40c819cd724);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2107cd65eb8>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：评论分类饼图  ——  pyecharts\n",
    "pie_data = pd.pivot_table(data,index=['group'],values=['item_id'],aggfunc=[len])\n",
    "pie_data.reset_index(inplace=True)\n",
    "pie_data.sort_values(by=('len','item_id'),ascending=False,inplace=True)\n",
    "size = pie_data[('len','item_id')]\n",
    "labels = pie_data['group']\n",
    "print(labels,size)\n",
    "# pie = Pie('评论分类饼图', title_pos='center')\n",
    "# attr = list(labels)\n",
    "# v1 = list(size)\n",
    "# pie.add('', attr, v1,radius=[40, 75],label_text_color=None,is_label_show=True,legend_orient='vertical',legend_pos='left')\n",
    "file_name = 'pie_' + title_class + '_output.html'\n",
    "# pie.render(os.path.join('./data_list',file_name))\n",
    "# pie\n",
    "pie = (Pie().add('',[list(z) for z in zip(labels, size)],radius=[\"40%\", \"75%\"],).set_global_opts(title_opts=opts.TitleOpts(title='评论分类饼图'),legend_opts=opts.LegendOpts(orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"),).set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {d}%\")))\n",
    "pie.render_notebook()\n",
    "# pie.render(os.path.join('./data_list',file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"df55a805119740a0952d2a0111cdcf9b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        var chart_df55a805119740a0952d2a0111cdcf9b = echarts.init(\n",
       "            document.getElementById('df55a805119740a0952d2a0111cdcf9b'), 'white', {renderer: 'canvas'});\n",
       "        var option_df55a805119740a0952d2a0111cdcf9b = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5c0f\\u7c7b\",\n",
       "            \"data\": [\n",
       "                23,\n",
       "                29,\n",
       "                33,\n",
       "                47,\n",
       "                56,\n",
       "                102,\n",
       "                107,\n",
       "                109,\n",
       "                113,\n",
       "                127,\n",
       "                130,\n",
       "                186,\n",
       "                214,\n",
       "                334,\n",
       "                410,\n",
       "                426,\n",
       "                608,\n",
       "                790,\n",
       "                814,\n",
       "                826,\n",
       "                851,\n",
       "                852,\n",
       "                882,\n",
       "                910,\n",
       "                1073,\n",
       "                1168,\n",
       "                1272,\n",
       "                1618,\n",
       "                1801,\n",
       "                1841,\n",
       "                1917,\n",
       "                2000,\n",
       "                2534\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c7b\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5c0f\\u7c7b\": true\n",
       "            },\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"\\u9910\\u5177\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5c0f\\u7c7b\\u6761\\u5f62\\u56fe\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_df55a805119740a0952d2a0111cdcf9b.setOption(option_df55a805119740a0952d2a0111cdcf9b);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2107cc7bd30>"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单变量：小类条形图  ——  pyecharts\n",
    "hbar_data = pd.pivot_table(data,index=['cate'],values=['item_id'],aggfunc=[len])\n",
    "hbar_data.reset_index(inplace=True)\n",
    "hbar_data.sort_values(by=('len','item_id'),ascending=True,inplace=True)\n",
    "title_name = hbar_data['cate']\n",
    "size = hbar_data[('len','item_id')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(size)\n",
    "# bar = Bar('小类条形图 ',width=800, height=1000)\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# bar.add('评论数', x_axis, y_axis,is_convert=True,is_label_show=True,label_pos='right')\n",
    "file_name = 'hbar_' + title_class + '_output.html'\n",
    "# bar.render(os.path.join('./data_list',file_name))\n",
    "# bar\n",
    "hbar = (Bar().add_xaxis(x_axis_list).add_yaxis('小类', y_axis_list).reversal_axis().set_series_opts(label_opts=opts.LabelOpts(position=\"right\")).set_global_opts(title_opts=opts.TitleOpts(title='小类条形图')))\n",
    "hbar.render_notebook()\n",
    "# hbar.render(os.path.join('./data_list',file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"57bda3ea55da4ece8ed47e7aecfb36ac\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        var chart_57bda3ea55da4ece8ed47e7aecfb36ac = echarts.init(\n",
       "            document.getElementById('57bda3ea55da4ece8ed47e7aecfb36ac'), 'white', {renderer: 'canvas'});\n",
       "        var option_57bda3ea55da4ece8ed47e7aecfb36ac = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5c0f\\u7c7b\",\n",
       "            \"data\": [\n",
       "                \"0.84\",\n",
       "                \"0.79\",\n",
       "                \"0.77\",\n",
       "                \"0.75\",\n",
       "                \"0.75\",\n",
       "                \"0.74\",\n",
       "                \"0.73\",\n",
       "                \"0.73\",\n",
       "                \"0.72\",\n",
       "                \"0.72\",\n",
       "                \"0.72\",\n",
       "                \"0.71\",\n",
       "                \"0.70\",\n",
       "                \"0.69\",\n",
       "                \"0.69\",\n",
       "                \"0.68\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.67\",\n",
       "                \"0.66\",\n",
       "                \"0.66\",\n",
       "                \"0.66\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.65\",\n",
       "                \"0.64\",\n",
       "                \"0.64\",\n",
       "                \"0.63\",\n",
       "                \"0.62\",\n",
       "                \"0.58\",\n",
       "                \"0.52\"\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c7b\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5c0f\\u7c7b\": true\n",
       "            },\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLabel\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"rotate\": -90,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u9178\\u5976\\u673a\",\n",
       "                \"\\u5200\\u5177\",\n",
       "                \"\\u9762\\u5305\\u673a/\\u591a\\u58eb\\u7089\",\n",
       "                \"\\u5fae\\u6ce2\\u7089/\\u70e4\\u7bb1\",\n",
       "                \"\\u4fdd\\u6e29\\u676f\",\n",
       "                \"\\u679c\\u76d8\",\n",
       "                \"\\u5957\\u9505\",\n",
       "                \"\\u7535\\u538b\\u529b\\u7172\",\n",
       "                \"\\u716e\\u9505/\\u7096\\u9505\",\n",
       "                \"\\u4fdd\\u6e29\\u76d2/\\u58f6\",\n",
       "                \"\\u5496\\u5561\\u673a\",\n",
       "                \"\\u69a8\\u6c41/\\u6405\\u62cc\",\n",
       "                \"\\u6c64/\\u5976\\u9505\",\n",
       "                \"\\u7535\\u996d\\u7172\",\n",
       "                \"DIY\\u5c0f\\u5bb6\\u7535\",\n",
       "                \"\\u53a8\\u623f\\u6536\\u7eb3\",\n",
       "                \"\\u9152\\u5177\",\n",
       "                \"\\u714e\\u9505/\\u5e73\\u5e95\\u9505\",\n",
       "                \"\\u9910\\u5177\",\n",
       "                \"\\u4fdd\\u9c9c\\u5bb9\\u5668\",\n",
       "                \"\\u7535\\u997c\\u94db/\\u70e7\\u70e4\\u76d8\",\n",
       "                \"\\u716e\\u86cb\\u5668\",\n",
       "                \"\\u53a8\\u623f\\u7528\\u5177\",\n",
       "                \"\\u62bd\\u6cb9\\u70df\\u673a/\\u7076\\u5177\",\n",
       "                \"\\u7535\\u78c1\\u7089\",\n",
       "                \"\\u7535\\u6c34\\u58f6 /\\u7535\\u6c34\\u74f6\",\n",
       "                \"\\u6c34/\\u8336\\u5177\",\n",
       "                \"\\u7827\\u677f\",\n",
       "                \"\\u7535\\u7096/\\u7535\\u84b8\\u9505\",\n",
       "                \"\\u53a8\\u76c6\\u6c34\\u69fd\",\n",
       "                \"\\u7092\\u9505\",\n",
       "                \"\\u8c46\\u6d46\\u673a\",\n",
       "                \"\\u7897\\u7b77\\u6d88\\u6bd2\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5c0f\\u7c7b\\u8bc4\\u8bba\\u5206\\u6570\\u67f1\\u72b6\\u56fe \"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_57bda3ea55da4ece8ed47e7aecfb36ac.setOption(option_57bda3ea55da4ece8ed47e7aecfb36ac);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x29740b179b0>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 双变量：小类、评论分数柱状图  ——  pyecharts\n",
    "data['sentiment_score'] = data['sentiment_score'].astype(float)\n",
    "bar_data = pd.pivot_table(data,index=['cate'],values=['sentiment_score'],aggfunc=[np.mean])\n",
    "bar_data.reset_index(inplace=True)\n",
    "bar_data.sort_values(by=('mean','sentiment_score'),ascending=False,inplace=True)\n",
    "f = lambda x: '%.2f'%x\n",
    "bar_data[('mean','sentiment_score')] = bar_data[('mean','sentiment_score')].map(f)\n",
    "title_name = bar_data['cate']\n",
    "score = bar_data[('mean','sentiment_score')]\n",
    "x_axis_list = list(title_name)\n",
    "y_axis_list = list(score)\n",
    "# bar = Bar('小类评论分数柱状图 ',width=1500, height=400)\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# bar.add('评论分数', x_axis, y_axis,xaxis_rotate=45,is_label_show=True)\n",
    "file_name = 'bar_' + title_class + '_output.html'\n",
    "# bar.render(os.path.join('./data_list',file_name))\n",
    "# bar\n",
    "bar = (Bar().add_xaxis(x_axis_list).add_yaxis('小类', y_axis_list).set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-90)),title_opts=opts.TitleOpts(title='小类评论分数柱状图 ')))\n",
    "bar.render_notebook()\n",
    "# bar.render(os.path.join('./data_list',file_name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 双变量：价格、评论分数散点图  ——  pyecharts\n",
    "# sentiment_score = data['sentiment_score'].astype(float)\n",
    "# pro_price = data['pro_price'].astype(float)\n",
    "# x_axis_list = list(sentiment_score)\n",
    "# y_axis_list = list(pro_price)\n",
    "# x_axis = x_axis_list\n",
    "# y_axis = y_axis_list\n",
    "# scatter = Scatter('价格评论分数散点图')\n",
    "# scatter.add('', x_axis, y_axis, symbol_size=5,is_visualmap=True)\n",
    "# scatter.render('./data_list/scatter_all_output.html')\n",
    "# scatter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'echarts-wordcloud':'https://assets.pyecharts.org/assets/echarts-wordcloud.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "    <div id=\"6a6378e80c3b41b7977a4def6987fbbf\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts', 'echarts-wordcloud'], function(echarts) {\n",
       "        var chart_6a6378e80c3b41b7977a4def6987fbbf = echarts.init(\n",
       "            document.getElementById('6a6378e80c3b41b7977a4def6987fbbf'), 'white', {renderer: 'canvas'});\n",
       "        var option_6a6378e80c3b41b7977a4def6987fbbf = {\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"wordCloud\",\n",
       "            \"shape\": \"diamond\",\n",
       "            \"rotationRange\": [\n",
       "                0,\n",
       "                0\n",
       "            ],\n",
       "            \"rotationStep\": 45,\n",
       "            \"girdSize\": 20,\n",
       "            \"sizeRange\": [\n",
       "                10,\n",
       "                100\n",
       "            ],\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u559c\\u6b22\",\n",
       "                    \"value\": 2937,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(73,143,143)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6ee1\\u610f\",\n",
       "                    \"value\": 2468,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(148,100,119)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d28\\u91cf\",\n",
       "                    \"value\": 2345,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(18,160,8)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fdd\\u6e29\",\n",
       "                    \"value\": 1831,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(92,160,110)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4ef7\\u683c\",\n",
       "                    \"value\": 1459,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(91,156,91)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6548\\u679c\",\n",
       "                    \"value\": 1316,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(16,146,121)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b9e\\u7528\",\n",
       "                    \"value\": 1189,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(130,39,154)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5f88\\u5feb\",\n",
       "                    \"value\": 1172,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(68,139,146)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u503c\\u5f97\",\n",
       "                    \"value\": 1030,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(54,60,151)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9001\\u8d27\",\n",
       "                    \"value\": 959,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(73,30,1)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u7528\",\n",
       "                    \"value\": 924,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(123,145,107)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b9e\\u60e0\",\n",
       "                    \"value\": 891,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(75,23,116)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u989c\\u8272\",\n",
       "                    \"value\": 839,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(31,23,70)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u901f\\u5ea6\",\n",
       "                    \"value\": 825,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(136,153,22)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7269\\u6d41\",\n",
       "                    \"value\": 795,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(69,58,108)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u54c1\\u724c\",\n",
       "                    \"value\": 755,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(53,102,158)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5feb\\u9012\",\n",
       "                    \"value\": 739,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(80,43,48)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6ca1\\u7528\",\n",
       "                    \"value\": 709,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(9,20,30)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u597d\\u770b\",\n",
       "                    \"value\": 688,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(65,46,63)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u914d\\u9001\",\n",
       "                    \"value\": 682,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(7,72,139)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6f02\\u4eae\",\n",
       "                    \"value\": 637,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(85,139,16)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5916\\u89c2\",\n",
       "                    \"value\": 618,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(37,8,153)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5305\\u88c5\",\n",
       "                    \"value\": 604,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(42,9,155)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5927\\u5c0f\",\n",
       "                    \"value\": 596,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(98,64,58)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u6d17\",\n",
       "                    \"value\": 571,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(117,156,15)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u676f\\u5b50\",\n",
       "                    \"value\": 569,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(10,85,148)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9505\\u5b50\",\n",
       "                    \"value\": 566,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(95,115,77)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u653e\\u5fc3\",\n",
       "                    \"value\": 531,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(150,74,74)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670b\\u53cb\",\n",
       "                    \"value\": 529,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(132,61,126)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5bb9\\u91cf\",\n",
       "                    \"value\": 505,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(109,155,30)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u670d\\u52a1\",\n",
       "                    \"value\": 501,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(142,152,138)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63a8\\u8350\",\n",
       "                    \"value\": 485,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(146,36,96)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fbf\\u5b9c\",\n",
       "                    \"value\": 474,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(83,0,31)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4fe1\\u8d56\",\n",
       "                    \"value\": 450,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(0,102,60)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u88c5\",\n",
       "                    \"value\": 448,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(56,11,102)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u53cc\\u7acb\\u4eba\",\n",
       "                    \"value\": 447,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(122,63,86)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6027\\u4ef7\\u6bd4\",\n",
       "                    \"value\": 442,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(87,68,140)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65f6\\u95f4\",\n",
       "                    \"value\": 437,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(23,136,119)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5f88\\u6f02\\u4eae\",\n",
       "                    \"value\": 427,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(108,159,115)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u76d6\\u5b50\",\n",
       "                    \"value\": 404,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(148,5,120)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0d\\u9508\\u94a2\",\n",
       "                    \"value\": 391,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(49,47,99)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73bb\\u7483\",\n",
       "                    \"value\": 389,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(53,59,27)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u724c\\u5b50\",\n",
       "                    \"value\": 364,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(151,105,119)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4f7f\\u7528\\u65b9\\u4fbf\",\n",
       "                    \"value\": 347,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(10,75,69)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c0f\\u5de7\",\n",
       "                    \"value\": 346,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(73,89,140)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u58f0\\u97f3\",\n",
       "                    \"value\": 342,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(152,26,57)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u51c0\",\n",
       "                    \"value\": 327,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(81,9,136)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5200\\u5177\",\n",
       "                    \"value\": 322,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(12,30,114)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9002\\u5408\",\n",
       "                    \"value\": 316,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(114,56,34)\"\n",
       "                        }\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5546\\u54c1\\u8d28\\u91cf\",\n",
       "                    \"value\": 314,\n",
       "                    \"textStyle\": {\n",
       "                        \"normal\": {\n",
       "                            \"color\": \"rgb(138,114,112)\"\n",
       "                        }\n",
       "                    }\n",
       "                }\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [],\n",
       "            \"selected\": {},\n",
       "            \"show\": true\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8bc4\\u8bba\\u8bcd\\u4e91\\u56fe\"\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_6a6378e80c3b41b7977a4def6987fbbf.setOption(option_6a6378e80c3b41b7977a4def6987fbbf);\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2107ce454a8>"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 词云  ——  pyecharts \n",
    "data_cut_words = pd.DataFrame(data.astype(str))\n",
    "# data_cut_words['cut_comment'] = data_duplicate_words['seg_comment'].apply(cut_words)\n",
    "# stopwords = load_stopwords()\n",
    "stopwords = [line.strip() for line in open('./常见中文停用词表.txt', encoding='gbk').readlines()]\n",
    "# 保存全局分词，用于词频统计\n",
    "segments = []\n",
    "# 普通分词及停用词判断\n",
    "for index, row in data_cut_words.iterrows():\n",
    "    content = row[5]\n",
    "    # TextRank 关键词抽取，只获取固定词性\n",
    "    words = jieba.cut(content,cut_all=False)\n",
    "    # splitedStr = ''\n",
    "    for word in words:\n",
    "        # 停用词判断，如果当前的关键词不在停用词库中才进行记录\n",
    "        if word not in stopwords:\n",
    "            # 记录全局分词\n",
    "            segments.append(word)\n",
    "            # splitedStr += word + ' '\n",
    "word_counts = collections.Counter(segments) # 对分词做词频统计\n",
    "word_counts_top10 = word_counts.most_common(50) # 获取前50最高频的词\n",
    "# print ('文本词频最高的前50个词是: {}'.format(word_counts_top10)) # 输出检查\n",
    "# 设置中文字体\n",
    "# font_path = os.path.join('C:\\Windows\\Fonts', 'FZYTK.TTF')\n",
    "# 生成词云\n",
    "# wc = WordCloud(font_path=font_path, margin=2, scale=10, max_words=200, min_font_size=4,random_state=42, background_color='white', max_font_size=150)\n",
    "# wc.generate_from_frequencies(word_counts)\n",
    "# 获取文本词排序，可调整 stopwords\n",
    "# process_word = WordCloud.process_text(wc, text)\n",
    "# sort = sorted(process_word.items(), key=lambda e: e[1], reverse=True)\n",
    "# 获取文本词频最高的前50个词\n",
    "# print('文本词频最高的前50个词是: {}'.format(sort[:50]))\n",
    "\n",
    "# words = []\n",
    "# counts = []\n",
    "\n",
    "# for item in word_counts_top10:\n",
    "#     word = item[0]\n",
    "#     count = item[1]\n",
    "#     words.append(word)\n",
    "#     counts.append(count)\n",
    "    \n",
    "# attr = words\n",
    "# value = counts\n",
    "# wordcloud = WordCloud(width=800, height=400)\n",
    "# wordcloud.add('评论词云图', attr, value,word_size_range=[10, 100],shape='diamond')\n",
    "file_name = 'wordcloud_' + title_class + '_output.html'\n",
    "# wordcloud.render(os.path.join('./data_list',file_name))\n",
    "# wordcloud\n",
    "wordcloud = (WordCloud().add(\"\", word_counts_top10 , word_size_range=[10, 100], shape=SymbolType.DIAMOND).set_global_opts(title_opts=opts.TitleOpts(title='评论词云图')))\n",
    "wordcloud.render_notebook()\n",
    "# wordcloud.render(os.path.join('./data_list',file_name))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
